<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <meta name="twitter:site" content="@metroui">
    <meta name="twitter:creator" content="@pimenov_sergey">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="Metro 4 Components Library">
    <meta name="twitter:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta name="twitter:image" content="https://metroui.org.ua/images/m4-logo-social.png">

    <meta property="og:url" content="https://metroui.org.ua/v4/index.html">
    <meta property="og:title" content="Metro 4 Components Library">
    <meta property="og:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta property="og:type" content="website">
    <meta property="og:image" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:secure_url" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:type" content="image/png">
    <meta property="og:image:width" content="968">
    <meta property="og:image:height" content="504">

    <meta name="author" content="Sergey Pimenov">
    <meta name="description" content="The most popular HTML, CSS, and JS library in Metro style.">
    <meta name="keywords" content="HTML, CSS, JS, Metro, CSS3, Javascript, HTML5, UI, Library, Web, Development, Framework">

    <link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon">
    <link rel="icon" href="../../favicon.ico" type="image/x-icon">

    <link href="../../metro/css/metro-all.css?ver=@@b-version" rel="stylesheet">
    <link href="../../metro/css/schemes/red-alert.css" rel="stylesheet">

    <title>Cube demo - Metro 4 :: Popular HTML, CSS and JS library</title>
</head>
<body class="bg-dark fg-white">
    <div class="container">
        <h1 class='text-center'>Metro 4 Components Library</h1>
        <h4 class='text-center'>Cube component demo</h4>

        <div class="mt-6" id="demo-cube" data-role="cube" data-custom="customCube" data-cells="10" data-margin="2"></div>
    </div>

    <script>

        var a_top = [];
        var a_left = [];
        var a_right = [];

        function customCube(element){
            var sides = ['top', 'left', 'right'];

            function toggle(cell, func, timeout){
                var side = cell.data("side");
                var id = cell.data("id");
                var array = Array(window["a_"+side]);
                setTimeout(function(){
                    if (func === 'on') {
                        cell.addClass("light");
                        array.push(id);
                    } else {
                        cell.removeClass("light");
                        array.splice(array.indexOf(id), 1);
                    }
                }, timeout);
            }

            var t = 1;
            $.each(sides, function(){
                for(var i = 1; i <= 10; i++) {
                    var array = Array(window["a_"+this]);
                    var id, timeout = $.random(100, 500), cell;

                    do {
                        id = $.random(1, 100);
                    } while (array.indexOf(id) > -1);

                    cell = $(element).find("."+this+"-side .cell-id-"+id);

                    toggle(cell, 'on', 100 * t);
                    toggle(cell, 'off', 200 * t);
                    t++;
                }
            });

            setTimeout(function(){
                customCube(element);
            }, 1000)
        }
    </script>

    <script src="../../metro/js/metro.js"></script>
    <!-- ads-script -->
</body>
</html>